/*
* Copyright (C) Microsoft. All rights reserved.  
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not 
* use this file except in compliance with the License.  You may obtain a copy 
* of the License at http://www.apache.org/licenses/LICENSE-2.0  
* 
* THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 
* WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 
* MERCHANTABLITY OR NON-INFRINGEMENT. 
*
* See the Apache License, Version 2.0 for specific language governing 
* permissions and limitations under the License.
*
*/

#include "pch.h"
#include <db/db_index_definition.h>
#include <db/db_field_definition_t.h>

namespace test_wrappers { namespace storage {

index_definition::index_definition() :
    _userIndexId(0),
    _primary(false),
    _unique(true)
{
}

index_definition::index_definition(
    const field_id& userIndexId,
    const std::wstring& name,
    const unsigned int& attributes) :
    _userIndexId(userIndexId),
    _name(name),
    _primary(attributes & primary_index ? true : false),
    _unique(attributes & unique_index ? true : false)
{
}

field_id index_definition::userIndexId() const
{
    return _userIndexId;
}

std::wstring index_definition::name() const
{
    return _name;
}

bool index_definition::primary() const
{
    return _primary;
}

bool index_definition::unique() const
{
    return _unique;
}

const std::vector<index_field_definition>& index_definition::indexFields() const
{
    return _indexFields;
}

void index_definition::addIndexField(
    const index_field_definition& indexField)
{
    _indexFields.push_back(indexField);
}

}}// namespace test_wrappers::storage
